<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!doctype html>
<html>
<head>
<title>个人资料管理-修改密码</title>
<%@ include file="../../../common/base.jsp" %>
</head>

<body id="body">
<!--head-->
<div id="head">
	<%@ include file="../../../common/head.jsp" %>
</div>
<!--head end-->
<!--container-->
<div id="container">
	<div id="pageId" style="display: none;">04-03-01</div>
		<!--sidebar-->
		<%@ include file="../../../common/menu.jsp" %>
	    <!--sidebar-->
    <!--main-->
    <div class="main">
    	<div class="location">
        	系统管理<span>&gt;</span>个人资料管理<span>&gt;</span>密码修改
        </div>
        <!--content-->
        <div class="content">
        	<h2 class="tit_blue">密码修改(带<span class="red">*</span>号为必填字段)</h2>
            <div class="inputInfoList3">
                <ul>
                    <li>
                    	<input type="hidden" id="operatorId" name="operatorId" value="${ossOperatorVO.operatorId }">
                        <label>登录名</label><span>${ossOperatorVO.loginName }</span>
                    </li>
                    <li>
                        <label>注册时间</label><span>${ossOperatorVO.createTimeDesc}</span>
                    </li>
                    <li>
                        <label>旧密码</label>
                        <input type="password" onFocus="this.style.border = '1px solid #2A7CCF'"  id="oldPassword" name="oldPassword" class="text" onBlur="passwordBlur('oldPassword',0);this.style.border = '1px solid #D5D5D5'">
                        <span class="red">*</span>
                        <i class="s_tips" id="oldPasswords" style="display: none;"></i>
						<i class="e_tips" id="oldPassworde" style="display: none;">&nbsp;</i>
						<p class="zhu_shi_1" id="oldPasswordZhu" style="display: none;"></p>
                    </li>
                    <li>
                        <label>新密码</label>
                        <input type="password" onFocus="this.style.border = '1px solid #2A7CCF'"  id="password" name="password" class="text" onBlur="passwordBlur('password',1);this.style.border = '1px solid #D5D5D5'">
                        <span class="red">*</span>
                        <i class="s_tips" id="passwords" style="display: none;"></i>
						<i class="e_tips" id="passworde" style="display: none;">&nbsp;</i>
						<p class="zhu_shi_1" id="passwordZhu" style="display: none;"></p>
                    </li>
                    <li>
                        <label>确认新密码</label>
                        <input type="password" onFocus="this.style.border = '1px solid #2A7CCF'"  id="conPassword" name="conPassword" class="text" onBlur="conPasswordBlur();this.style.border = '1px solid #D5D5D5'">
                        <span class="red">*</span>
                        <i class="s_tips" id="conPasswords" style="display: none;"></i>
						<i class="e_tips" id="conPassworde" style="display: none;">&nbsp;</i>
						<p class="zhu_shi_1" id="conPasswordZhu" style="display: none;"></p>
                    </li>
                </ul>
                <div class="button_wrap button_wrap2">
                	<a href="javascript:;" onClick="updatePassword();">修改</a>
                </div>
            </div>
        </div>
        <!--content-->
        <!--foot-->
        <div id="foot">
        	<p>北京掌中彩信息科技有限公司  提供技术支持</p>
        </div>
        <!--foot-->
    </div>
    <!--main-->
</div>
<!--container-->
<script src="${pageContext.request.contextPath}/static/js/basic.js"></script>
<script type="text/javascript">
//密码
function passwordBlur(id,type,focusFlag){
	var pwd = $("#"+id).val();
	$("#"+id+"Zhu").html("");
	$("#"+id+"s").hide();
	$("#"+id+"e").hide();
	$("#"+id+"Zhu").hide();
	if(pwd ==null || pwd.length < 1){
		$("#"+id+"e").show();
		$("#"+id+"Zhu").show();
		if(type == 0){
			$("#"+id+"Zhu").append("旧密码不能为空");
		}else{
			$("#"+id+"Zhu").append("新密码不能为空");
		}	
		if(focusFlag){
			locationFocus(id);
		}
		return false;
	}else if(pwd.length < 6){		
		if(type == 0){
			$("#"+id+"s").show();
			return true;
		}else{
			$("#"+id+"e").show();
			$("#"+id+"Zhu").show();
			$("#"+id+"Zhu").append("新密码长度不能小于6位");
		}
		if(focusFlag){
			locationFocus(id);
		}
		return false;
	}else{
		$("#"+id+"s").show();
		return true;
	}
}
//确认密码
function conPasswordBlur(focusFlag){
	var conPassword = $("#conPassword").val();
	var password = $("#password").val();
	$("#conPasswordZhu").html("");
	$("#conPasswords").hide();
	$("#conPassworde").hide();
	$("#conPasswordZhu").hide();
	if(conPassword ==null || conPassword.length < 1){
		$("#conPassworde").show();
		$("#conPasswordZhu").show();
		$("#conPasswordZhu").append("确认新密码不能为空");
		if(focusFlag){
			locationFocus(id);
		}
		return false;
	}else if (conPassword != password){
		$("#conPassworde").show();
		$("#conPasswordZhu").show();
		$("#conPasswordZhu").append("两次输入密码不一致！");
		if(focusFlag){
			locationFocus("conPassword");
		}
		return false;
	}else{
		$("#conPasswords").show();
		return true;
	}
}

function updatePassword(){
	var oldPassword = $("#oldPassword").val();
	var password = $("#password").val();
	var conPassword = $("#conPassword").val();
	
	if(!passwordBlur("oldPassword",0,true)){
		return false;
	}
	if(!passwordBlur("password",1,true)){
		return false;
	}
	if(!conPasswordBlur(true)){
		return false;
	}
	//开始提交更新渠道信息
    $.ajax({ 				//请求登录处理页
    	contentType:"aplication/x-www-form-urlencoded; charset=UTF-8",
        url: "user/updateUserPassword",  
        //传送请求数据
        data: { password: password, 
        	oldPassword: oldPassword
        },
        success: function(data, status){   
        	$("#oldPassword").val("");
        	$("#password").val("");
        	$("#conPassword").val("");
            prompt.alert(data.msg);                	
	    },error: function (data, status, e){
	    	prompt.alert(data.msg);
	    }
    });
}
</script>
</body>
</html>